from fastapi import APIRouter, Body, File, UploadFile
from fastapi.params import Param

from application.generate.entity_generate_service import EntityGoCodeGenerator
from application.generate.entity_struct_generate_service import EntityStructGeneratorService

router = APIRouter(
    tags=['generator'],
    prefix="/generate",
)


@router.post('/entity.go')
def entity_go_generator(
        model: str = Body(..., description='模型名称'),
        query: str = Body(..., description='需求')
):
    return EntityGoCodeGenerator.agent_generate(query=query, model_name=model)


@router.post('/entity.go/struct')
def entity_go_generator_excel(
        model: str = Param(..., description='模型名称'),
        excel_file: UploadFile = File(default=..., alias='file', description='excel文件')
):
    return EntityStructGeneratorService.generate_entity_struct(excel_file.file, model)
